import Vue from 'vue'
import { getAction } from '@/api/manage'
import { ACCESS_TOKEN } from '@/store/mutation-types'
export const TableMixin = {
  data () {
    return {
      alert: {
        clear: true
      },
      url: {
        pageList: ''
      },
      selectedRowKeys: [],
      selectedRows: [],
      queryParam: {},
      loadData: parameter => {
        return getAction(
          this.url.pageList,
          Object.assign(parameter, this.queryParam)
        ).then(res => {
          return res.data
        })
      },
      // file-upload
      headers: {
        Authorization: 'Bearer ' + Vue.ls.get(ACCESS_TOKEN)
      }
    }
  },
  methods: {
    onSelectChange (selectedRowKeys, selectedRows) {
      this.selectedRowKeys = selectedRowKeys
      this.selectedRows = selectedRows
    },
    queryPage (bool = false) {
      this.$refs.table.refresh(bool)
    }
  }
}
